package com.user.dao;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.user.dao.IUserDao;
import com.user.bean.User;

/**
 * 用户模型的DAO(Data Access Object).
 * 主要用于处理用户类相关的请求.
 * 
 * @author 
 */
public class UserDao extends HibernateDaoSupport implements IUserDao {

	@Override
	public void addUser(User user) {
		this.getHibernateTemplate().save(user);
	}

	@Override
	public void updateUser(User user) {
		this.getHibernateTemplate().update(user);
	}

	@Override
	public void deleteUser(User user) {
		this.getHibernateTemplate().delete(user);
	}
	
	@Override
	public User getUserByUsername(String username) {
		User user = this.getHibernateTemplate().get(User.class, username);
		return user;
	}
}
